package edu.magix.pres;

import com.japisoft.formula.*;
import java.util.Vector;
import com.japisoft.formula.Variant;
import com.japisoft.formula.lib.AbstractLib;
import com.japisoft.formula.lib.LibManager;
import com.japisoft.formula.lib.standard.AbstractFunction;

public class FnElement extends AbstractFunction {
        public FnElement() {
        	super( "element", new Class[] { Double.class, Vector.class } );
        }

        public Variant evaluate( ListOfArgument args ) {
        	double index = args.getArgumentAt( 0 ).getDoubleValue();
        	Vector list = args.getArgumentAt( 1 ).getListValue();
        	return new Variant( list.elementAt((int)index - 1) );
	}
}